package org.ly.utils;

import java.security.MessageDigest;

/**
 * 2013-09-11
 * -----
 * 密码MD5加密
 * 
 * @author Yong
 */
public class MD5 {

    public static String getMd5(String string){
        MessageDigest md = null;
        StringBuffer sb = null;
		try {
			md = MessageDigest.getInstance("md5");
			md.update(string.getBytes("utf-8"));
			byte[] hascode = md.digest();
			
			sb = new StringBuffer();
			for (byte temp : hascode) {
				sb.append(Character.forDigit((temp >> 4) & 0xf, 16));
				sb.append(Character.forDigit(temp & 0xf, 16));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
        return sb.toString();

    }

}
